import 'package:flutter/material.dart';

class TabBarController extends StatefulWidget {
  @override
  TabBarControllerState createState() {
    return TabBarControllerState();
  }
}

class TabBarControllerState extends State<TabBarController>
    with SingleTickerProviderStateMixin {
  TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = new TabController(
      vsync: this,
      length: 6,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Row(
          children: <Widget>[
            Expanded(
                child: TabBar(
              //controller
              controller: this._tabController,
              isScrollable: true,
              tabs: <Widget>[
                Tab(text: "欧美"),
                Tab(text: "日韩"),
                Tab(text: "港台"),
                Tab(text: "大陆"),
                Tab(text: "SM"),
                Tab(text: "AV"),
              ],
            ))
          ],
        ),
      ),
      body: TabBarView(
        //controller
        controller: this._tabController,
        children: <Widget>[
          MyCategoryList(),
          MyCategoryList(),
          MyCategoryList(),
          MyCategoryList(),
          MyCategoryList(),
          MyCategoryList(),
        ],
      ),
    );
  }

  @override
  void dispose() {
    super.dispose();
  }
}

class MyCategoryList extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ListView(
      children: <Widget>[
        SizedBox(height: 10),
        ListTile(
          title: Text("经典大片"),
          subtitle: Text("银河护卫队"),
          leading: Image.network(
              "http://photo.16pic.com/00/52/66/16pic_5266584_b.jpg"),
        ),
        ListTile(
          title: Text("经典大片"),
          subtitle: Text("银河护卫队"),
          leading: Image.network(
              "http://photo.16pic.com/00/52/66/16pic_5266584_b.jpg"),
        ),
        ListTile(
          title: Text("经典大片"),
          subtitle: Text("银河护卫队"),
          leading: Image.network(
              "http://photo.16pic.com/00/52/66/16pic_5266584_b.jpg"),
        ),
        ListTile(
          title: Text("经典大片"),
          subtitle: Text("银河护卫队"),
          leading: Image.network(
              "http://photo.16pic.com/00/52/66/16pic_5266584_b.jpg"),
        ),
      ],
    );
  }
}
